<template>
  <div class="container">
    <headerBar :title="headerBarTitle" @changeLan="changeLan"></headerBar>
    <div class="all" :style="{paddingTop: pdt+'px'}">
      <alphabetpage :list="groups" :letters="letters" />
    </div>
  </div>
</template>

<script>
// import { formatTime } from '@/utils/index'
import headerBar from '@/components/headerBar'
import home from '@/api/home'
import alphabetpage from '@/components/alphabetpage'
import { pinyin } from '@/utils/hz2py_full'
export default {
  components: {
    alphabetpage,
    headerBar
  },
  methods: {
    changeLan(val) {
      this.local = val
    },
    routerToUrl(url) {
      wx.navigateTo({
        url
      })
    }
  },
  async onReachBottom() {
    if (this.pageNum < this.lastPage) {
      // 如果当前页面小于最后一页
      this.pageNum = this.nextPage // 把当前页面，变成下一页面的页面数
      // this.getCustomerList() // 进行对后台数据的请求
    } else {
      wx.showToast({
        // 如果当前页面处于最后一页，就提示没有数据了
        title: '没有更多了',
        icon: 'none',
        duration: 2000
      })
    }
  },
  // 下拉刷新
  async onPullDownRefresh() {
    this.pageNum = 1 // 只请求第一页面的列表数据
    //  this.getCustomerList() // 进行数据的请求
    wx.stopPullDownRefresh() // 停止下拉刷新
  },
  onUnLoad() {
    this.pageNum = 1
    this.pageSize = 7
    this.lastPage = 100
    this.nextPage = 1
  },
  data() {
    return {
      pdt: 66,
      pageNum: 1,
      pageSize: 20,
      lastPage: 100,
      nextPage: 1,
      local: wx.getStorageSync('local'),
      letters: [
        'A',
        'B',
        'C',
        'D',
        'E',
        'F',
        'G',
        'H',
        'I',
        'J',
        'K',
        'L',
        'M',
        'N',
        'O',
        'P',
        'Q',
        'R',
        'S',
        'T',
        'U',
        'V',
        'W',
        'X',
        'Y',
        'Z'
      ],
      groups: [],
      mydata: {
        id: ''
      }
    }
  },
  onShow() {
    this.local = wx.getStorageSync('local')
  },
  onLoad(options) {
    this.local = wx.getStorageSync('local')
    this.pdt = this.globalData.CustomBar
    this.groups =
      options.name == 'supplier'
        ? wx.getStorageSync('supplierList')
        : wx.getStorageSync('customerList')
    this.headerBarTitle =
      options.name == 'supplier'
        ? this.local.selectSupplier
        : this.local.selectCustomer
  },
  created() {}
}
</script>

<style scoped lang='scss'>
@import 'index';
</style>
